package cn.kgc.fcm.dsbank.dto;

import cn.kgc.fcm.dsbank.constant.DsBankConstant;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class ResultDTO<T> {

    private Integer code;
    private String msg;
    private T obj;

    public static ResultDTO buildSuccess(){
        return new ResultDTO(DsBankConstant.DefaultInfo.SUCCESS_CODE,DsBankConstant.DefaultInfo.SUCCESS_MSG,null);
    }

    public static ResultDTO buildSuccess(Object o){
        return  new ResultDTO(DsBankConstant.DefaultInfo.SUCCESS_CODE,DsBankConstant.DefaultInfo.SUCCESS_MSG,o);
    }

    public static ResultDTO buildSuccess(String msg,Object o){
        return  new ResultDTO(DsBankConstant.DefaultInfo.SUCCESS_CODE,msg,o);
    }

    public static ResultDTO buildError(){
        return new ResultDTO(DsBankConstant.DefaultInfo.ERROR_CODE,DsBankConstant.DefaultInfo.ERROR_MSG,null);
    }

    public static ResultDTO buildError(String msg){
        return new ResultDTO(DsBankConstant.DefaultInfo.ERROR_CODE,msg,null);
    }
}
